#ifndef MSGWND_H
#define MSGWND_H

#include <QWidget>

namespace Ui {
class MsgWnd;
}

class MsgWnd : public QWidget
{
    Q_OBJECT

public:
    static void ShowNormalInfo(const QString content1, const QString content2 = "", const QString content3 = "", QWidget* parent = Q_NULLPTR, bool modal = true);

    // 弹窗显示 等待一定时间
    static void ShowWaitInfo(const QString content1, const QString content2 = "", const QString content3 = "", QWidget* parent = Q_NULLPTR, bool modal = true);

    // 弹窗显示 确认擦除已经存在的sn
    static void ConfirmEraseExistSN(const QString content1 = "", const QString content2 = "", const QString content3 = "", QWidget* parent = Q_NULLPTR, bool modal = true);

    // 弹窗显示 确认删除action记录
    static void ConfirmDeleteActionRecord(const QString content1 = "", const QString content2 = "", const QString content3 = "", QWidget* parent = Q_NULLPTR, bool modal = true);

    // 弹窗显示 确认删除action记录
    static void ConfirmDeleteSNRecord(const QString content1 = "", const QString content2 = "", const QString content3 = "", QWidget* parent = Q_NULLPTR, bool modal = true);

    // 弹窗显示 扫描或输入新的SN
    static void ScanInputNewSN(const QString content1 = "", const QString content2 = "", const QString content3 = "", QWidget* parent = Q_NULLPTR, bool modal = true);

    // 弹窗显示发送短信失败
    static void SendMsgMsgFail(const QString content1 = "", const QString content2 = "", const QString content3 = "", QWidget* parent = Q_NULLPTR, bool modal = true);
protected:

    enum EMsgBoxType {
        EMsgBoxType_NormalInfo = 0,
        EMsgBoxType_ShowWait,
        EMsgBoxType_ConfirmEraseExistSN,
        EMsgBoxType_ConfirmDelAction,
        EMsgBoxType_ConfirmDelSN,
        EMsgBoxType_ScanInputNewSN,
        EMsgBoxType_SendMsgFail
    };

    enum EMsgBoxBottomBtn {
        EMsgBoxType_None = 0,
        EMsgBoxType_One = 1,
        EMsgBoxType_Two = 2
    };

    MsgWnd() = default;
    MsgWnd(EMsgBoxType type, QWidget* parent, QString content1, QString content2, QString content3, bool modal = true);

    ~MsgWnd();

    void show_timer(bool show, int32_t time = 10);

    void showEvent(QShowEvent *event) override;
    void closeEvent(QCloseEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    bool eventFilter(QObject *watched, QEvent *event) override;

    void resetShowPage();
    void resetContent(bool flag = true);

protected slots:
    void on_btn_sec_normal_ok_clicked();
    void on_btn_nor_normal_cancel_clicked();

    void event_close_wnd();

    // 扫描输入新sn界面按钮
    void on_btn_nor_quit_clicked();
    void on_btn_sec_submit_clicked();

    // 发送信息失败提示界面按钮
    void on_btn_nor_skip_clicked();
    void on_btn_sec_re_send_clicked();
private:
    void showTopleftQuitBtn(bool show);

    void showWnd(const EMsgBoxType type, const QString content1, QString content2, QString content3);

private:
    static MsgWnd* g_msg_view;

    Ui::MsgWnd *ui;

    QWidget*		parent_;        // 容器
    EMsgBoxType     type_;          // 类型
    QString			content1_;      // 入参内容记录
    QString			content2_;      // 入参内容记录
    QString         content3_;      // 入参内容记录

    QTimer*			timer_;         // 倒计时时钟
    int32_t						timer_cnt_;                 // 当前显示的倒计时数字
    bool						timer_flag_;                // 是否显示倒计时
};

#endif // MSGWND_H
